package com.pyg.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.pyg.manager.service.SpecificationService;
import com.pyg.pojo.PageResult;
import com.pyg.pojo.PygResult;
import com.pyg.vo.Specification;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/specification")
public class SpecificationController {

    @Reference(timeout = 1000000)
    private SpecificationService specificationService;

    @RequestMapping("findByPage/{page}/{rows}")
    public PageResult findByPage(@PathVariable Integer page, @PathVariable Integer rows){
        PageResult result = specificationService.findByPage(page, rows);
        return result;
    }

    @RequestMapping("findOne/{id}")
    public Specification findOne(@PathVariable Long id){
        return specificationService.findOne(id);
    }

    @RequestMapping("add")
    public PygResult add(@RequestBody Specification specification){
        return specificationService.add(specification);
    }

    @RequestMapping("/update")
    public PygResult update(@RequestBody Specification specification){
        return specificationService.update(specification);
    }

    @RequestMapping("/delete")
    public PygResult delete(Long[] ids){
        return specificationService.delete(ids);
    }

    @RequestMapping("/findSpecList")
    public List<Map> findSpecList(){
        List<Map> specList = specificationService.findSpecList();
        return specList;
    }

}
